<?php
define('YOUR_APP_ID', '154298721334849');
define('YOUR_APP_SECRET', '06cf702bd487a527505b1dd369d2c4b9');

$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Bobby Bopper\n";
fwrite($fh, $stringData);
$stringData = "Tracy Tanner\n";
fwrite($fh, $stringData);
fclose($fh);


function get_facebook_cookie($app_id, $app_secret) {
  $args = array();
  parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
  ksort($args);
  $payload = '';
  foreach ($args as $key => $value) {
    if ($key != 'sig') {
      $payload .= $key . '=' . $value;
    }
  }
  if (md5($payload . $app_secret) != $args['sig']) {
    return null;
  }
  return $args;
}

function getUser() {
	$cookie = get_facebook_cookie(YOUR_APP_ID, YOUR_APP_SECRET);

	if ($cookie) {
//	$user = json_decode(file_get_contents(
//		'https://graph.facebook.com/me?access_token='.$cookie['access_token']));
		
		echo file_get_contents('https://graph.facebook.com/me?access_token='.$cookie['access_token']);
	}
	else {
		echo '';
	}
}

getUser();

?>